import 'package:flutter/material.dart';
import 'package:poet/components/poet_item.dart';
import 'package:poet/pages/share_page/select_bkg_page.dart';

class SharePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _SharePage();
  }
}

class _SharePage extends State<SharePage> {
  String _checkedLines = "";

  void _nextStep() {
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => SelectBkgPage(),
      ),
    );
  }

  bool get enableNextStep => !_checkedLines.isEmpty;

  void _checkLineCallback(String checkedLines) {
    setState(() {
      _checkedLines = checkedLines;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('选择诗句'),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.arrow_forward),
            onPressed: enableNextStep ? _nextStep : null,
          )
        ],
      ),
      body: Column(
        children: <Widget>[
          Expanded(
            child: PoetItem(
              shareMode: true,
              checkLineCallback: _checkLineCallback,
            ),
          ),
        ],
      ),
    );
  }
}
